<?php

namespace app\common\validate;

use think\Validate;

class PostMan extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
	    'name' => 'require',
	    'mobile' => 'require|checkMobile'
    ];
    /**
     * 提示消息
     */
    protected $message = [
	    'name' => '请填写姓名',
	    'mobile' => '手机号码格式不正确'
    ];
    
    
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => [],
        'edit' => [],
    ];
    
    protected function checkMobile($value, $rule, $data) {
    	$preg = '/^1\d{10}$/';
    	if(!preg_match($preg, $value)) {
    		return '手机号码格式不正确';
	    }
    	
    	return true;
    }
}
